// 主界面
;
define(function(require, exports, module) {
	'use strict';
	var util = require("util");
	var base = require("base");
	var leftMenu = require("../leftMenu/leftMenu");
	var topMenu = require("../topMenu/topMenu");
	var router = require("../hash/pageRouter");
	var dialog = require("dialog");
	var validate = require("validate");
	var databind = require("databind");
	var css_receivableNoticeDetail = require("./receivableNoticeDetail.css");
	var js_receivableNoticeList = require("./receivableNoticeList.js");
	var receivablesId;
	var type;
	var init = function(page) {
		receivablesId = page.params.receivablesId;
		type = page.params.type;
		inquireReceivablesDetail();
		initEvent();
		router.init();
		js_receivableNoticeList.init();
	};
	var initEvent = function() {
		//若未登录，则返回登陆页面
		if (base.getData("sid") == null || base.getData("sid") == "" || base.getData("sid") == undefined) {
			top.location.href = "../login/login.html";
		}
		
		$(".receivablesNoticeList").on("click",function(){
			location.href="../financing/receivableNoticeList.html";
		});
		
		//审核提交
		$(".dialogBtn").on("click",function(){
			databind.submitDom($(".receivablesContent"),function(data){
				base.alert(1,"收款记录审核成功");
				location.href="../financing/receivableNoticeList.html";
			});
		});
		
	};

	//获取收款记录明细(收款通知)
	var inquireReceivablesDetail = function(){
		base.fnAjax({
			action: "inquireReceivablesDetail.json",
			oData: {
				receivablesId:receivablesId
			}, //传递参数
			fnSuccess: function(data) {
				if (data.status == 200) {
					databind.fillForm($(".receivablesContent"),data.datas[0]);
					databind.disableInput($(".receivablesContent"));
					
					if(type=="approve"){
						databind.enableInput($(".loan_info5"));
						$(".dialogBtn").removeClass("none");
					}
				} else {
					base.alert(3, "信息获取失败");
				}
			}
		});
	}
		
	return {
		init: init
	};
});